<HTML>
<HEAD>
<TITLE>Insert Iterators</TITLE>
<LINK REL=StyleSheet HREF="../rw.css" TYPE="text/css" TITLE="Rogue Wave Standard Stylesheet"></HEAD>
<BODY BGCOLOR=#FFFFFF>
<A HREF="inputiterators.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="insert-iterator.html"><IMG SRC="images/bnext.gif" WIDTH=25 HEIGHT=21 ALT="Next file" BORDER=O></A><DIV CLASS="DOCUMENTNAME"><B>Rogue Wave C++ Standard Library Reference Guide</B></DIV>
<H2>Insert Iterators</H2>
<P><B>Module:</B>&nbsp;&nbsp;Standard C++ Library&nbsp;&nbsp;&nbsp;<B>Library:</B>&nbsp;&nbsp;<A HREF="2-8.html">Iterators</A></P>

<PRE><HR><B><I><A HREF="insert-iterator.html">insert_iterator</A></I></B> <IMG SRC="images/inherits.gif"> <B><I><A HREF="iterator.html">iterator</A></I></B><HR></PRE>

<UL>
<LI><A HREF="#sec1">Local Index</A></LI>
<LI><A HREF="#sec2">Summary</A></LI>
<LI><A HREF="#sec3">Synopsis</A></LI>
<LI><A HREF="#sec4">Description</A></LI>
<LI><A HREF="#sec5">Interface</A></LI>
<LI><A HREF="#sec6">See Also</A></LI>
<LI><A HREF="#sec7">Standards Conformance</A></LI>
</UL>
<A NAME="sec1"><H3>Local Index</H3></A>
No Entries
<A NAME="sec2"><H3>Summary</H3></A>
<P>An iterator adaptor that allows an iterator to insert into a container rather than overwrite elements in the container</P>
<A NAME="sec3"><H3>Synopsis</H3></A>

<PRE>#include &lt;iterator&gt;

namespace std {
  template &lt;class Container&gt;
  class insert_iterator;

  template &lt;class Container&gt;
  class back_insert_iterator;

  template &lt;class Container&gt;
  class front_insert_iterator;
}
</PRE>
<A NAME="sec4"><H3>Description</H3></A>
<P>Insert iterators are iterator adaptors that let an iterator <I>insert</I> new elements into a collection rather than overwrite existing elements when copying to a container. There are several types of insert iterator classes.</P>
<UL>
<LI><P CLASS="LIST">The class <B><I><A HREF="back-insert-iterator.html">back_insert_iterator</A></I></B> is used to insert items at the end of a collection. The function <SAMP><A HREF="back-insert-iterator.html">back_inserter()</A></SAMP> can be used with an iterator inline, to create an instance of a <B><I>back_insert_iterator</I></B> for a particular collection type.</P></LI>
<LI><P CLASS="LIST">The class <B><I><A HREF="front-insert-iterator.html">front_insert_iterator</A></I></B> is used to insert items at the start of a collection. The function <SAMP><A HREF="front-insert-iterator.html">front_inserter()</A></SAMP> creates an instance of a <B><I>front_insert_iterator</I></B> for a particular collection type. </P></LI>
<LI><P CLASS="LIST">An <B><I><A HREF="insert-iterator.html">insert_iterator</A></I></B> inserts new items into a collection at a location defined by an iterator supplied to the constructor. Like the other insert iterators, <B><I>insert_iterator</I></B> has a helper function called <SAMP><A HREF="insert-iterator.html">inserter()</A></SAMP>, which takes a collection and an iterator into that collection, and creates an instance of the <B><I>insert_iterator</I></B>. </P></LI>
</UL>
<A NAME="sec5"><H3>Interface</H3></A>

<UL><PRE>namespace std{ 

  template &lt;class Container&gt;
  class insert_iterator : public
       iterator&lt;output_iterator_tag,void,void,void,void&gt;; {

    public:
      typedef Container container_type;
      insert_iterator(Container&amp;, typename
                      Container::iterator);
      insert_iterator&lt;Container&gt;&amp;
      operator=(const typename Container::value_type&amp;);
      insert_iterator&lt;Container&gt;&amp; operator*();
      insert_iterator&lt;Container&gt;&amp; operator++();
      insert_iterator&lt;Container&gt;&amp; operator++(int);
    };

  template &lt;class Container&gt;
  class back_insert_iterator : public
         iterator&lt;output_iterator_tag,void,void,void,void&gt; ; {

    public:
      typedef Container container_type;
      explicit back_insert_iterator(Container&amp;);
      back_insert_iterator&lt;Container&gt;&amp;
      operator=(const typename Container::value_type&amp;);
      back_insert_iterator&lt;Container&gt;&amp; operator*();
      back_insert_iterator&lt;Container&gt;&amp; operator++();
      back_insert_iterator&lt;Container&gt; operator++(int);
    };

  template &lt;class Container&gt;
  class front_insert_iterator : public
        iterator&lt;output_iterator_tag,void,void,void,void&gt;;
  {

    public:
      typedef Container container_type;
      explicit front_insert_iterator(Container&amp;);
      front_insert_iterator&lt;Container&gt;&amp;
      operator=(const typename Container::value_type&amp;);
      front_insert_iterator&lt;Container&gt;&amp; operator*();
      front_insert_iterator&lt;Container&gt;&amp; operator++();
      front_insert_iterator&lt;Container&gt; operator++(int);
  };

  template &lt;class Container, class Iterator&gt;
  insert_iterator&lt;Container&gt; inserter(Container&amp;, Iterator);
 
  template &lt;class Container&gt;
  back_insert_iterator&lt;Container&gt; <SAMP><A HREF="back-insert-iterator.html">back_inserter</A></SAMP>(Container&amp;);

  template &lt;class Container&gt;
  front_insert_iterator&lt;Container&gt; 
                        <SAMP><A HREF="front-insert-iterator.html">front_inserter</A></SAMP>(Container&amp;);
}
</PRE></UL>
<A NAME="sec6"><H3>See Also</H3></A>
<P><B><I><A HREF="back-insert-iterator.html">back_insert_iterator</A></I></B>, <B><I><A HREF="front-insert-iterator.html">front_insert_iterator</A></I></B>, <B><I><A HREF="insert-iterator.html">insert_iterator</A></I></B></P>
<A NAME="sec7"><H3>Standards Conformance</H3></A>
<P><I>ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 24.4.2</I></P>

<BR>
<HR>
<A HREF="inputiterators.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="insert-iterator.html"><IMG SRC="images/bnext.gif" WIDTH=20 HEIGHT=21 ALT="Next file" BORDER=O></A></BODY>
</HTML>
